package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.lis.entity.WkKnowledgeIssue;
import com.ysd.lis.mapper.WkKnowledgeIssueMapper;
import com.ysd.lis.service.WkKnowledgeIssueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * cold_chain.t_user 服务实现类
 * </p>
 *
 * @author peng
 * @since 2024-03-04
 */
@Service
@Slf4j
public class WkKnowledgeIssueServiceImpl extends ServiceImpl<WkKnowledgeIssueMapper, WkKnowledgeIssue> implements WkKnowledgeIssueService {

    @Autowired
    WkKnowledgeIssueMapper wkKnowledgeIssueMapper;

    @Override
    public Result getIssueObjectById(String id) {
        WkKnowledgeIssue wkKnowledgeIssue = this.getById(id);
        return Result.succ(1, "查询成功！", wkKnowledgeIssue);
    }

    @Override
    public Result addKnowledgeIssue(WkKnowledgeIssue issue) {
        int insert = wkKnowledgeIssueMapper.insert(issue);
        if (insert > 0) {
            return Result.succ(1, "添加成功", issue);
        } else {
            return Result.succ(400, "添加失败", "");
        }
    }

    @Override
    public Result editKnowledgeIssue(WkKnowledgeIssue issue) {
        int updateById = wkKnowledgeIssueMapper.updateById(issue);
        if (updateById > 0) {
            return Result.succ(1, "修改成功", issue);
        } else {
            return Result.succ(400, "修改失败", "");
        }
    }

    @Override
    public Result deletKnowledgeIssue(WkKnowledgeIssue issue) {
        int deleteById = wkKnowledgeIssueMapper.deleteById(issue.getId());
        if (deleteById > 0) {
            return Result.succ(1, "删除成功", issue);
        } else {
            return Result.fail("删除失败");
        }
    }
}
